package com.tencent.iov.cowin.befsale.clue.value.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * @Describe: 跟进记录状态类型
 * @author: xiamu
 * @created: 2021-12-01 18:22:10
 * @version: 1.0
 */
@Getter
@AllArgsConstructor
public enum FollowRecordSecondStatusEnum {
    //0 新建线索 2 验证 5 下发(下发总部客户),  10分配跟进人，11变更跟进人,  15产品介绍, 16到店接待, 17试乘试驾，18下订, 19交车，20实销， 21战败申请，25意向变更 30 同意战败，31 拒绝战败， 33 战败激活
    //新建到总部客户表
    INIT(0, "创建有效线索"),
    INIT_INVALID(1, "创建无效线索"),
    //新建到总部客户表
    VALIDATION(2, "验证"),
    //下发到经销商
    TRANS(5, "下发"),
    //已有分配人
    DISTRIBUTION(10, "分配跟进人"),
    CHANGE_DISTRIBUTION(11, "变更跟进人"),
    FOLLOW_PRODUCT_INTRODUCE(15, "产品介绍"),
    FOLLOW_CHECKIN(16, "到店接待"),
    FOLLOW_DRIVE_TEST(17, "试乘试驾"),
    FOLLOW_ORDERED(18, "下订"),
    FOLLOW_DELIVERY(19, "交车"),
    FOLLOW_CONSUMED(20, "实销"),
    FOLLOW_FAIL_APPLY(21, "战败申请"),
    FOLLOW_DRIVE_APPOINT(22, "试驾预约"),
    CHANGE_INTENTION(25, "意向变更"),
    APPROVAL_FAIL_AGREE(30, "同意战败"),
    APPROVAL_FAIL_REFUSED(31, "拒绝战败"),
    APPROVAL_FAIL_ACTIVATE(33, "战败激活");

    Integer code;
    String name;

    /**
     * 会出现跟进过期的枚举
     *
     * @param code 分类2
     * @return 是否可以计算跟进逾期
     */
    public static Boolean checkFollowExpire(Integer code) {
        return DISTRIBUTION.getCode().equals(code) || FOLLOW_PRODUCT_INTRODUCE.getCode().equals(code)
                || FOLLOW_CHECKIN.getCode().equals(code) || FOLLOW_DRIVE_TEST.getCode().equals(code)
                || FOLLOW_ORDERED.getCode().equals(code) || FOLLOW_DELIVERY.getCode().equals(code);
    }

    public static FollowRecordSecondStatusEnum getByCode(Integer secondStatus) {
        return Stream.of(FollowRecordSecondStatusEnum.values()).filter(second ->
                second.getCode().equals(secondStatus)).findAny().orElse(null);
    }
}
